package com.plum.admin.modules.front;

import cn.hutool.core.util.RandomUtil;
import com.plum.admin.common.util.R;
import com.plum.admin.common.util.WeatherUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2021/8/23 14:30
 */
@RestController
@RequestMapping("/dashboard")
@Api(tags = "工作台数据")
public class DashboardController {
    @Autowired
    private WeatherUtil weatherUtil;
    @ApiOperation("工作台数据")
    @GetMapping("consoleData")
    public R<Object> dashboard(){
        Map<String,Object> param= new HashMap<>(16);
        Map<String,Object> visits=new HashMap<>(16);
        visits.put("dayVisits", RandomUtil.randomDouble(10000,99999,2, RoundingMode.HALF_UP));
        visits.put("rise", RandomUtil.randomDouble(10,99,2, RoundingMode.HALF_UP));
        visits.put("decline", RandomUtil.randomDouble(10,99,2, RoundingMode.HALF_UP));
        visits.put("amount", RandomUtil.randomDouble(9999,99999,2, RoundingMode.HALF_UP));
        param.put("visits",visits);
        Map<String,Object> saleroom=new HashMap<>(16);
        visits.put("weekSaleroom", RandomUtil.randomDouble(10000,99999,2, RoundingMode.HALF_UP));
        visits.put("amount", RandomUtil.randomDouble(99999,999999,2, RoundingMode.HALF_UP));
        visits.put("degree", RandomUtil.randomDouble(10,99,2, RoundingMode.HALF_UP));
        param.put("saleroom",saleroom);
        Map<String,Object> orderLarge=new HashMap<>(16);
        visits.put("weekLarge", RandomUtil.randomDouble(10000,99999,2, RoundingMode.HALF_UP));
        visits.put("rise", RandomUtil.randomDouble(99999,999999,2, RoundingMode.HALF_UP));
        visits.put("decline", RandomUtil.randomDouble(10,99,2, RoundingMode.HALF_UP));
        visits.put("amount", RandomUtil.randomDouble(10,99,2, RoundingMode.HALF_UP));
        param.put("orderLarge",orderLarge);
        Map<String,Object> volume=new HashMap<>(16);
        visits.put("weekLarge", RandomUtil.randomDouble(10000,99999,2, RoundingMode.HALF_UP));
        visits.put("rise", RandomUtil.randomDouble(99999,999999,2, RoundingMode.HALF_UP));
        visits.put("decline", RandomUtil.randomDouble(10,99,2, RoundingMode.HALF_UP));
        visits.put("amount", RandomUtil.randomDouble(10,99,2, RoundingMode.HALF_UP));
        param.put("volume",volume);
        return R.ok(param);
    }
    @GetMapping("/weatherInfo")
    @ApiOperation("查询今日天气")
    public R<Object> findWeather(){
        return R.ok(weatherUtil.getWeatherInfo());
    }
}
